using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.CRMDomain;
using ShivamEMR.Model.DataInterfaces.CRMDataInterf;
using ShivamEMR.Model;

namespace ShivamEMR.Web.Areas.CRM.Controllers
{   
    public class AppointmentStatusController : Controller
    {
		private readonly IAppointmentStatusRepository appointmentstatusRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public AppointmentStatusController() //: this(new AppointmentStatusRepository())
        {
            this.appointmentstatusRepository = Registry.RepositoryFactory.GetAppointmentStatusRepository();
        }

        public AppointmentStatusController(IAppointmentStatusRepository appointmentstatusRepository)
        {
			this.appointmentstatusRepository = appointmentstatusRepository;
        }

        //
        // GET: /AppointmentStatus/

        public ViewResult Index()
        {
            return View(appointmentstatusRepository.All);//Including(appointmentstatus => appointmentstatus.Appointments));
        }

        //
        // GET: /AppointmentStatus/Details/5

        public ViewResult Details(int id)
        {
            return View(appointmentstatusRepository.Find(id));
        }

        //
        // GET: /AppointmentStatus/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /AppointmentStatus/Create

        [HttpPost]
        public ActionResult Create(AppointmentStatus appointmentstatus)
        {
            if (ModelState.IsValid) {
                appointmentstatusRepository.Create(appointmentstatus);
                appointmentstatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /AppointmentStatus/Edit/5
 
        public ActionResult Edit(int id)
        {
             return View(appointmentstatusRepository.Find(id));
        }

        //
        // POST: /AppointmentStatus/Edit/5

        [HttpPost]
        public ActionResult Edit(AppointmentStatus appointmentstatus)
        {
            if (ModelState.IsValid) {
                appointmentstatusRepository.Update(appointmentstatus);
                appointmentstatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /AppointmentStatus/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(appointmentstatusRepository.Find(id));
        }

        //
        // POST: /AppointmentStatus/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var a = appointmentstatusRepository.Find(id);
            appointmentstatusRepository.Delete(a);
            appointmentstatusRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

